#pragma once

using namespace System;
using namespace System::Diagnostics;
using namespace System::Collections::Generic;
using namespace System::Runtime::InteropServices;
using namespace System::Text;
using namespace System::Drawing;
using namespace System::IO;

namespace m4aSharp 
{
	public ref class Atom
	{
	internal:
		Atom(String^ name);
		void SetData(array<Byte>^ data);

		void AddChildAtom(Atom^ child);

	public:		
		property String^ Name
		{
			String^ get()
			{
				return _name;
			}
		}

		Object^ InterpretData();

		property array<Byte>^ Data
		{
			array<Byte>^ get()
			{
				return _data;
			}
		}

		property IList<Atom^>^ Atoms
		{
			IList<Atom^>^ get()
			{
				return _atoms;
			}
		}

		property Atom^ Parent
		{
			Atom^ get()
			{
				return _parent;
			}
		}
		
		virtual String^ ToString() override;

	private :
		Image^ ExtractImage();
		void SetParent(Atom^ atom);		
		UInt16 UInt16FromBigEndian(int offset);

		String^ _name;
		array<Byte>^ _data;
		IList<Atom^>^ _atoms;
		Atom^ _parent;
	};
}
